package org.gd.hellojavacore.tests;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

public class DateTest {

    public static void main(String...str) throws ParseException {
        try {
            Integer expireSec = 60;

            Date date = new Date();
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(date);
            calendar.add(Calendar.SECOND, expireSec);

            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", new Locale("uk", "UA"));

            System.out.println(format.format(date));
            System.out.println(format.format(calendar.getTime()));


            Date newDate = format.parse("2013-03-19 00:00:00.0000f00");
            System.out.println(format.format(newDate));

            System.out.printf("\n\n");
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }

        try {
            System.out.println("Apr 19, 2013 10:20:56 AM");
            Date date1 = new Date("Apr 19, 2013 10:20:56 AM");
            System.out.println(date1);
            System.out.println(new Date());
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }

        try {
            Date date2 = new Date("Thu Apr 18 12:41:05 FEST 2013");
            System.out.println(date2);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }

        try {
            Date date3 = new Date("2013-09-24T11:45:08.376+03:00");
            System.out.printf("date3: %s", date3);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
    }
}
